<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="verify-v1" content="GhqqxcUvquMq3bT3rRDkoC4eh6fg37klKDd+qpktjBA=" />
    <title>Album Preview</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <!--script type="text/javascript" src="/media/jquery/jquery-1.3.2.min.js"></script-->
    <link rel="alternate" href="/cooliris/?url={{ url }}" type="application/rss+xml" title="" id="gallery" />
    <script type="text/javascript" src="http://lite.piclens.com/current/piclens.js"></script>
        
    <script type="text/javascript">
    function loadurl(){
        var url = $('#url').val();
        
        if( url.indexOf("http://")!=0 && url.indexOf("https://")!=0 ){
            url = 'http://' + url;
        }
        
        if(url.indexOf("http://fashion-girls.appspot.com/")!=0){
            //url = "http://fashion-girls.appspot.com/fetch?url="+url;
        }
        
        window.location.href = '/preview/?url='+url;
    }

    function go(){
            var url = $('#url').val();
            
            if( url.indexOf("http://")!=0 && url.indexOf("https://")!=0 ){
                url = 'http://' + url;
            }
        
            if(url.indexOf("http://fashion-girls.appspot.com/")!=0){
                url = "http://fashion-girls.appspot.com/fetch/?url="+url;
            }
            
            //alert(url);
            $.get(url,
                function(data){
                    $('#pictures').html("");
                    //alert("Data Loaded: " + data);
                    //alert(typeof data);
                    
                    var xmlDom = $(data);
                    xmlDom.find("thumbnail").each(
                        function( intIndex ){
                            //alert($(this));
                            //alert($(this).text());
                            var img_url = $(this).text()
                            //img_url = img_url.replace(/<\!--\[CDATA\[/, "");
                            //img_url = img_url.replace(/\]\]-->/, "");
                            //alert(img_url);
                            
                            var img_html = '<span style="width:72px;text-align:center;margin:3px;"><a href="#'+intIndex+'"><img src="'+img_url+'"/></a></span>'
                            if((intIndex+1)%2==0){
                                //img_html += '<br/>';
                            }
                            $('#pictures').append(img_html);
                        }
                    );
                    
                    $('#pictures').append("<hr/>");
                    
                    xmlDom.find("fullpic").each(
                        function( intIndex ){
                            //alert($(this));
                            //alert($(this).text());
                            var img_url = $(this).text()
                            //img_url = img_url.replace(/<\!--\[CDATA\[/, "");
                            //img_url = img_url.replace(/\]\]-->/, "");
                            //alert(img_url);
                            
                            //var img_element = document.createElement('img');
                            //img_element.setAttribute('src', img_url);
                            
                            var img_html = '<div style="text-align:center;margin:15px;"><a name="'+intIndex+'"/><img src="'+img_url+'"/></div>'
                            if((intIndex+1)%2==0){
                                //img_html += '<br/>';
                            }
                            
                            $('#pictures').append(img_html);
                        }
                    );
                    
                    
                }
            );
        }
        
        $(function(){
            var params = window.location.search;
            //alert(params);
            var url_key_str = "url=";
            var idx = params.indexOf(url_key_str);
            if(idx>0){
                params = params.substring(idx+url_key_str.length);
                //alert(params);
                var end_idx = params.indexOf("&");
                if(end_idx==-1){
                    end_idx = params.length;
                }
                var url = params.substring(0, end_idx);
                //alert(url);
                
                if( url.indexOf("http://")!=0 && url.indexOf("https://")!=0 ){
                    url = 'http://' + url;
                }
                $('#url').attr('value', url);
                $('#gallery').attr('href', '/cooliris/?url='+url);
                go();
            }
        });
    </script>
    <style>
    a img{ 
        border:0; 
    }
    </style>
</head>
<body style="background-color:black;color:white;">
<div class="main">
    <div>
        Album XML URL：<input type="text" name="url" id="url" value="http://fashion-girls.appspot.com/1/}" style="width:300px">
        <input type="button" onclick="loadurl()" title="Preview" value="Preview">
        <input type="button" onclick="PicLensLite.start()" title="Slide Show" value="Slide Show">
    <hr/>
        <div id="pictures" style="">
            <br/>
        </div>
    </div>
    <div class="clear">&nbsp;</div>
    <div class="g960 tc">
        <p id="copyright"></p>
    </div>
    <div class="clear">&nbsp;</div>
</div>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-9726605-4");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
